﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoolEngine.Engine;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace CoolEngine.Gui
{
    internal struct DrawInfo
    {
        public Texture2D Texture { get; set; }
        public Rectangle Location { get; set; }
        public Color Tint { get; set; }
    }
    public class TextBox : GuiControl
    {
        //public TextBox()
        //    : base()
        //{
        //    Text = new List<FormattedText>();
        //}
        public TextBox(CoolGame game, GuiRenderer renderer)
            : base(game, renderer)
        {
            Text = new List<FormattedText>();
        }
        public TextBox(CoolGame game, GuiRenderer renderer, GuiControl parent)
            : base(game, renderer,parent)
        {
            Text = new List<FormattedText>();
        }
        public List<FormattedText> Text { get; private set; }
        private static readonly string[] newLine = new string[] { Environment.NewLine };
        /// <summary>
        /// Writes the input to the console, without a new line.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <param name="colour">The colour.</param>
        [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "colour", Justification = "Learn to spell.")]
        public void Write(string input, Color colour)
        {
            string[] split = input.Split(newLine, StringSplitOptions.RemoveEmptyEntries);
            foreach (string line in split)
            {
                Text.Add(new FormattedText() { Colour = colour, Text = line });
            }
        }
        /// <summary>
        /// Writes the input to the console and a new line.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <param name="colour">The colour.</param>
        [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "colour", Justification = "Learn to spell.")]
        public void WriteLine(string input, Color colour)
        {
            Write(input + Environment.NewLine, colour);
        }
        /// <summary>
        /// Writes the input to the console and a new line.
        /// </summary>
        /// <param name="input">The input.</param>
        [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "colour", Justification = "Learn to spell.")]
        public void WriteLine(string input)
        {
            Write(input + Environment.NewLine, Color.White);
        }
        /// <summary>
        /// Writes the input to the console, without a new line.
        /// </summary>
        /// <param name="input">The input.</param>
        [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "colour", Justification = "Learn to spell.")]
        public void Write(string input)
        {
            Write(input, Color.White);
        }
    }
}
